<?php
$dbconnect = DBconnect::getInstance();

function displayAllManagers(){
	$dbconnect = DBconnect::getInstance();
	$query = $dbconnect->selectAllManagers();
	while($managers = mysql_fetch_assoc($query)){
		$name = $managers['man_name'];
		echo "<option value='$name'>$name</option>";
	}
}

function printFormToEditManager($managerName){
	$dbconnect = DBconnect::getInstance();
	$email = $dbconnect->getManagerEmail($managerName);
	echo "<form action='' method='post'><table><th>Edit $managerName</th>
			<tr><td>Manager Name</td><td><input type='text' name='editname' value='$managerName'></td></tr>
			<tr><td>Password</td><td><input type='password' name='editpassword'></td></tr>
			<tr><td>Email</td><td><input type='text' name='editemail' value='$email'></td></tr>
			<tr><td></td><td><input type='submit' name='update' value='Update Info'></table></form>";
}

if(isset($_POST['edit'])){
	printFormToEditManager($_POST['allmanagers']);
}

if(isset($_POST['update'])){
	$manager = new Manager(trim($_POST['editname']), trim($_POST['editpassword']), trim($_POST['editemail']));
	$dbconnect->updateManagerInfo($manager);
}
?>